<?
$this->headTitle('Log Viewer');
$this->headLink()->appendStylesheet($this->baseUrl('styles/log.css'));
?>
<div>
    <h1><?= $this->escape($this->channel); ?> on <?= $this->escape($this->year) . '-' . $this->escape($this->month) .'-' . $this->escape($this->day); ?></h1>

    <table id="log">
        <tr class="head">
            <th>Time</th>
            <th>Nick</th>
            <th>Message</th>
        </tr>
        <? $previousNick = null; ?>
        <? foreach ($this->data as $line) : ?>
        <? $isSameNick = ($previousNick == $line['nick']); ?>
        <tr class="<?= ($line['id'] % 2) ? 'highlight' : ''; ?>">
            <td id="line-<?= $line['id']; ?>" class="time">
                <a href="#line-<?= $line['id']; ?>">
                    <?= date('H:i', strtotime($line['timestamp'])); ?>
                </a>
            </td>
            <td class="nick"><?= $isSameNick ? '' : $this->escape($line['nick']); ?></td>
            <td class="msg"><?= $this->escape($line['message']); ?></td>
        </tr>
        <? $previousNick = $line['nick']; ?>
        <? endforeach; ?>
    </table>

    <div align="center">
        <?= $this->paginationControl($this->data, 'Elastic', 'logs/paginator.phtml'); ?>
    </div>
</div>